package com.syx.service.impl;

import com.syx.dao.CarDao;
import com.syx.entity.Car;
import com.syx.entity.Users;
import com.syx.service.CarService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class CarServiceImpl implements CarService {
    @Resource
    private CarDao carDao;

    @Override
    public List carList(Map map) {
        return carDao.carList(map);
    }

    @Override
    public List typeList() {
        return carDao.typeList();
    }

    @Override
    public List cityList(Integer pid) {
        return carDao.cityList(pid);
    }

    @Override
    public List colorList() {
        return carDao.colorList();
    }

    @Override
    public int add(Car car, Integer[] coids) {
        int i = carDao.add(car);
        if (i>0){
            Map map = new HashMap();
            map.put("cid",car.getCid());
            map.put("coids",coids);
            carDao.addcc(map);
        }
        return i;
    }

    @Override
    public int del(String cid) {
        Map map = new HashMap();
        map.put("cid",cid);
        int i = carDao.del(map);

//        if (i>0){
//            carDao.delcc(cid);
//        }
        return 1;
    }

    @Override
    public Map hx(Integer cid) {
        return carDao.hx(cid);
    }

    @Override
    public int update(Car car, Integer[] coids) {
        System.out.println(car.toString());
        int i = carDao.update(car);
        return i;
    }

    @Override
    public Users login(Users users) {
        return carDao.login(users);
    }




}
